package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.project.bean.InventoryBean;
import com.project.bean.WaitProductBean;
import com.project.mapper.IInventoryInfoMapper;
import com.project.mapper.IInventoryMapper;
import com.project.mapper.IWaitProductMapper;
import com.project.service.IInventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class InventoryServiceImpl implements IInventoryService {
    @Autowired
    private IWaitProductMapper waitProductMapper;
    @Autowired
    private IInventoryMapper inventoryMapper;
    @Autowired
    private IInventoryInfoMapper inventoryInfoMapper;
    @Override
    public String updateWaitProductStatus(String id, Integer waitProductStatus) {
        //查找待上架商品对象
        QueryWrapper<WaitProductBean> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("productId",id);
        WaitProductBean waitProductBean = waitProductMapper.selectOne(queryWrapper);

        //修改状态为新的
        //传进来的是1-下架，0上架，如果查出来的商品本身就是0（1），返回no
        waitProductBean.setProductStatus(waitProductStatus);
        waitProductMapper.updateById(waitProductBean);
        return "ok";
    }

    @Override
    public List<InventoryBean> monitorInventory() {
        //查询产品中低于阈值的产品

        //根据查询出来的产品，查询对应的所有商品
        return null;
    }
}
